home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5890 < prev    next >
Encoding:
Text File  |  1996-08-05  |  848 b   |  39 lines

  1. Path: news.kreonet.re.kr!usenet
  2. From: jwhahn@cair.kaist.ac.kr (Jung Hahn)
  3. Newsgroups: comp.lang.c++
  4. Subject: You want Recursion .... come and get it ... right here
  5. Date: Wed, 07 Feb 1996 11:22:52 GMT
  6. Organization: Applied Database Labs, K.A.I.S.T
  7. Message-ID: <31188b07.11954912@news.kreonet.re.kr>
  8. NNTP-Posting-Host: swine.kaist.ac.kr
  9. X-Newsreader: Forte Agent .99d/32.168
  10.  
  11. #include <stdio.h>
  12.  
  13. /*
  14.  *    I think this is what you need ..... a recursive function that 
  15.  *    printfs a string in order and with only a %c ... get it ?
  16.  */
  17.  
  18. foo( char *s, int len)
  19. {
  20. static int count=0;
  21.  
  22.     if ( count++ < len) {
  23.         printf( "%c", *s++);
  24.         foo( s, len);
  25.         }
  26. }
  27.  
  28. void main( void)
  29. {
  30.     char *t = "Hello World\n";
  31.  
  32.     foo( t, strlen(t));
  33. }    
  34. ___________
  35.  
  36.     Name:  Jung w. Hahn
  37.     Elm:   jwhahn@cair.kaist.ac.kr
  38.     Phone: 042-869-2959
  39.